﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeGenerator.Core
{
    public interface IDatabase
    {
        /// <summary>
        /// 测试数据库连接
        /// </summary>
        /// <param name="server"></param>
        /// <param name="errMessage"></param>
        /// <returns></returns>
        bool TestConnnect(ServerInfo server, out string errMessage);

        /// <summary>
        /// 获取数据库列表
        /// </summary>
        /// <returns></returns>
        IList<string> GetDatabaseList(ServerInfo server);

        /// <summary>
        /// 获取库中表列表
        /// </summary>
        /// <param name="server"></param>
        /// <returns></returns>
        IList<TableInfo> GetTableList(ServerInfo server, string dbName);

        /// <summary>
        /// 获取表结构信息
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="field">字段</param>
        /// <returns></returns>
        List<ColumnInfo> GetColumnInfoList(ServerInfo server, string dbName, string tableName);

        /// <summary>
        /// 获取表注释
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        string GetTableComments(ServerInfo server, string dbName, string tableName);

        #region 类型转换

        /// <summary>
        /// Sql类型转C#类型
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="isNull"></param>
        /// <returns></returns>
        NameElement GetNetType(string typeName, string isNull);

        /// <summary>
        /// Sql类型转Java类型
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="isNull"></param>
        /// <returns></returns>
        NameElement GetJavaType(string typeName); 
        #endregion
    }
}
